<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="ui" uri="http://com.am.tag" %>
<%@ include file="../common.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'userList.jsp' starting page</title>
    <script type="text/javascript" src="${path}/js/public/grid.js"></script>
  	<script type="text/javascript">
  	
  		function doSave()
  		{
  			openDailog("view","${path}/jsp/role/roleEdit.jsp",490,200,"添加角色",false,true,null,function(dlg){
  				
  				dlg.getIFrame().doSave();
  			});
  		}
  		
  		function doEdit()
  		{
  			if(!isSelectOne(mygrid))
  			{
  				alert("请选择一条记录进行修改");
  				return;
  			}
			openDailog("view","${path}/jsp/role/roleEdit.jsp",490,200,"修改角色",false,true,mygrid.getSelectedRecords()[0],function(dlg){
  				
  				dlg.getIFrame().doSave();
  			});
  		}
  		
  		function doDelete()
  		{
  			if(!isSelectOne(mygrid))
  			{
  				alert("请选择一条记录进行删除");
  				return;
  			}
  			if(confirm("你是否确定要删除此记录"))
  			{
  				var id = mygrid.getSelectedRecords()[0].id + "";
  				ajax.remoteCall("com.system.dao.RoleDao:delete",[id],function(reply){
  	    			var result = reply.getResult();
  	    			alert(result.value);
  	    			if(result.type == "success")
  	    			{
  	    				mygrid.reload();
  	    			}
  	    		});
  			}
  		}
  		
  		function doQuery()
  		{
  			resetGrid(mygrid,"queryForm");
  		}
  		
  		function setPrivilege(id)
  		{
			openDailog("view","${path}/jsp/role/setPrivilege.jsp?roleId=" + id,320,380,"设置权限",false,true,null,function(dlg){
  				dlg.getIFrame().doSave();
  			});
  		}
  		
  		function oprtRender(value,record,columnObj,grid,colNo,rowNo)
  		{
  			return "<a href='javascript:void(0)' style='text-decoration: none;' onclick='setPrivilege(" + grid.getColumnValue('id',rowNo) + ")'>设置权限</a>";
  		}
  		
  		function doExport()
  		{
  			$.gridToXls(mygrid,"com.system.provider.RoleListProvider","角色列表.xls","id,oprt");
  		}
  		
  	</script>
  </head>
  <body>
  	<table id="" cellSpacing="0" cellPadding="0" style="width:100%;height:100%;" border="0">
  		<tr>
			<td class="windowTitle">系统管理  &gt; 角色管理</td>
		</tr>
  		<tr id="">
			<td style="height:35px;width:100%" class="windowHead">	
				<form id="queryForm">
					<table cellSpacing="0" cellPadding="0" width="100%" height="100%" border="0" >
						<tr>
							<td>
								<ui:Permission value="role_add">
									<ui:Button type="save" onclick="doSave()">新增</ui:Button>
								</ui:Permission>
								<ui:Permission value="role_modify">
									<ui:Button type="edit" onclick="doEdit()">修改</ui:Button>
								</ui:Permission>
								<ui:Permission value="role_delete">
									<ui:Button type="delete" onclick="doDelete()">删除</ui:Button>
								</ui:Permission>
								<ui:Permission value="role_emport">
									<ui:Button type="export" onclick="doExport()">导出</ui:Button>
								</ui:Permission>
							</td>
						</tr>
					</table>
				</form>
				<br/>
				<a style="text-decoration: none;"></a>
			</td>
		</tr>
		<tr id="">
			<td style="width:100%;height:100%;overflow:hidden"  class="windowBody">
				<div id="mess_box" style="width:100%;height:100%;overflow:hidden">
					<ui:Grid id="mygrid" css="width:100%;height:100%"
				    		 onCellClicked="selectedSingleRow2"
				    		 dataProvider="com.system.provider.RoleListProvider:getData" >
				    	<ui:GridField name="id" header="ID" isChecked="true" align="center"/>
				    	<ui:GridField name="name" header="角色名称" align="center" width="15%"/>
				    	<ui:GridField name="oprt" header="操作" align="center" width="8%" render="oprtRender"/>
				    	<ui:GridField name="notes" header="角色描述" align="left" width="30%"/>
				    	<ui:GridField name="create_user" header="创建人" align="center" width="14%"/>
				    	<ui:GridField name="create_time" header="创建时间" align="center" width="15%"/>
				    	<ui:GridField name="modify_time" header="修改时间" align="center" width="15%"/>
			    	</ui:Grid>
		    	</div>
		    </td>
		</tr>
  	</table>
  	<script type="text/javascript">
		$().ready(function(){
			disableSelectAll(mygrid);
		});
	</script>
  </body>
</html>
